package com.yuantu.judiciary.model.word;

import lombok.Getter;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author kgwei
 */
@Getter
public enum ImageSourceType {

    /**
     * 网络图片
     */
    WEB(1),
    /**
     * 磁盘上图片
     */
    DISK(2),
    /**
     * 项目resources目录下图片
     */
    RESOURCE(3);

    private final int type;

    ImageSourceType(int type) {
        this.type = type;
    }

    private static final Map<Integer, ImageSourceType> TYPE_MAP = Stream.of(ImageSourceType.values())
            .collect(Collectors.toMap(ImageSourceType::getType, t -> t));

    public static ImageSourceType fromType(Integer type) {
        return TYPE_MAP.getOrDefault(type, ImageSourceType.WEB);
    }
}
